﻿package dt 
{
	import flash.display.MovieClip;
	/**
	 * ...
	 * @author Doan Nguyen Thuy Nha Truc (Bamboo)	
	 */
	public class CardPanel extends MovieClip
	{
		public var card1, card2: MovieClip;
		public var cardArr:Array;
		public function CardPanel() 
		{
			cardArr = new Array(card1, card2);
			hideAllCards();
		}
		
		/**
		 * @author Bamboo
		 * @param	cardPos start from 1 -> 2
		 * @param	cardCode start from 101 -> 413
		 */
		public function showCard(cardPos:int, cardCode:int):void {			
			if (cardCode != 0)
			{
				cardArr[cardPos - 1].visible = true;
				var temp:int = cardCode % 100;
				var ind:int = ((cardCode / 100) - 1) * 13 + (temp >7 ? temp : temp + 1) ;
				cardArr[cardPos - 1].gotoAndStop(ind);
			}
		}
		
		/**
		 * @author Bamboo
		 * @param	cards
		 */
		/*public function initCards(cards:String):void {
			
			var cardList:Array = cards.split(" ");
			
			for (var i:int = 0; i < cardList.length - 1; i++) {
				if ((i % 2) == 0) {
					showCard(cardList[i], cardList[i + 1]);
				}
			}
		}*/
		
		/**
		 * @author Bamboo
		 */
		public function hideAllCards():void {
			for (var i in cardArr) {
				cardArr[i].visible = false;
			}
		}
		
	}

}